#include "AfterOriSendDispatcher.h"
#include "OriBodyRecvRelayHandler.h"
#include "BeginConnInsDestHandlerB.h"

using namespace std;

ITransHandler::ExecuteResultCode AfterOriSendDispatcher::PreExecute(ClientContext &client,OVERLAPPED *ovl,DWORD *transCount)
{
	DWORD flags;
	BOOL result=::WSAGetOverlappedResult(client.DestSock(),client.OVL(),transCount,true,&flags);
	int errCode=::WSAGetLastError();
	if(!result)
	{
		return ITransHandler::ExecuteFatalError;
	}
	return ITransHandler::ExecuteOK;
}

ITransHandler* AfterOriSendDispatcher::HitFailedHandler()
{
	return new OriBodyRecvRelayHandler();
}

ITransHandler* AfterOriSendDispatcher::HittedHandler(const string &hittedUrl,DWORD transCount)
{
	return new BeginConnInsDestHandlerB(hittedUrl,transCount);
}